package com.ithe.shopweb.exception;

import com.ithe.shopweb.common.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 功能：全局异常处理器
 * 日期： 2024/4/8 21:44
 */

@ControllerAdvice
public class GlobalException {

    @ExceptionHandler(ServiceException.class)
    @ResponseBody
    public Result handle(ServiceException serviceException) {
        return Result.error(serviceException.getCode(), serviceException.getMessage());
    }
}
